﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary
{
    public class ProcessUtil
    {
        public static bool RunProcess(string applicationName, string applicationArgs)
        {
            bool isRun = false;
            System.Diagnostics.Process Proc;

            try
            {
                Proc = new System.Diagnostics.Process();
                Proc.StartInfo.FileName = applicationName;  // "notepad.exe";
                Proc.StartInfo.Arguments = applicationArgs;
                Proc.StartInfo.UseShellExecute = false;
                Proc.StartInfo.RedirectStandardInput = true;
                Proc.StartInfo.RedirectStandardOutput = true;

                Proc.Start();

                isRun = true;
            }
            catch
            {
                Proc = null;
            }
            return isRun;
        }

        public static bool RunProcess(string applicationName) 
        {
            bool isRun = false;
            System.Diagnostics.Process Proc;

            try
            {
                Proc = new System.Diagnostics.Process();
                Proc.StartInfo.FileName = applicationName;  // "notepad.exe";
                Proc.StartInfo.UseShellExecute = false;
                Proc.StartInfo.RedirectStandardInput = true;
                Proc.StartInfo.RedirectStandardOutput = true;

                Proc.Start();
                isRun = true;
            }
            catch
            {
                Proc = null;
            }
            return isRun;
        }
    }
}
